package com.ljf.framework.shutdown;

import com.ljf.framework.Async.AsyncManager;
import com.ljf.framework.log.LjfLogManager;
import com.ljf.framework.log.LjfLogService;
import com.ljf.framework.schedule.LjfScheduleManager;


/**
 * 说明：ljf框架关闭管理器
 *
 * @Auther: lijinfeng
 * @Date: 2024/8/5
 */
public class LjfShutdownManager {
    static LjfLogService log = LjfLogManager.getLogger(LjfShutdownManager.class);


    public static void setShutdown(){
        Runtime.getRuntime().addShutdownHook(new ExitHook());
    }

    public static void shutdown(){
        AsyncManager.shutdown();
        log.info("ljf框架关闭完成");
    }

    static class ExitHook extends Thread{
        public void run() {
            shutdown();
            LjfScheduleManager.shutdown();
        }
    }
}
